import React from 'react';
import api from "./api/index"

export default class ProxyDemo extends React.Component {
    componentDidMount() {
        /*
         * @description: @zww 跨域解决方案
         * @param {*}  开发模式下： react vue都提供了解决方案
         * @return {*} 生产模式下：jsonP,CORS，iframe.postMessage...等
         * npm run build === 打包后进入生产模式
         */
        fetch('/api/playlist/detail?id=3778678')
            .then(res => res.json())
            .then(data => {
                console.log(data);
            })
            .catch(error => {
                console.log(error);
            });
        fetch("/apinew/list").then(res => {
            res.json()
        }).then(data => {
            console.log(data)
        }).catch(e => {
            console.log(e)
        })
        api.getChengPin().then(res => res.json()).then(data => {
            console.log(data)
        })
        api.getLogin({
            user_id: 'iwen@qq.com',
            password: 'iwen123',
            verification_code: 'crfvw'
        }).then(res => res.json()).then(data => {
            console.log(data)
        })
    }

    render() {
        return (<div>
            <h1>跨域请求的配置</h1>
        </div>);
    }
}
